package com.tedu.pj.sys.controller;

import com.tedu.pj.common.pojo.Response;
import com.tedu.pj.sys.pojo.SysMenu;
import com.tedu.pj.sys.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *
 * </p>
 *
 * @author Song
 * @since 2020/10/16
 */
@RequestMapping("/menu/")
@RestController
public class SysMenuController {

    @Autowired
    SysMenuService sysMenuService;

    @GetMapping("doFindObjects")
    public Response doFindObjects() {
        return new Response(sysMenuService.findObjects());
    }

    @RequestMapping("doFindZtreeMenuNodes")
    public Response doFindZtreeMenuNodes() {
        return new Response(sysMenuService.findZtreeMenuNodes());
    }

    @PostMapping("doSaveObject")
    public Response doSaveObject(SysMenu entity) {
        sysMenuService.saveObject(entity);
        return new Response("save ok");
    }

    @RequestMapping("doUpdateObject")
    public Response doUpdateObject(SysMenu entity) {
        sysMenuService.updateObject(entity);
        return new Response("update ok");
    }


    @PostMapping("/doDeleteObject")
    public Response doDeleteObject(Integer id){
        sysMenuService.deleteObject(id);
        return new Response("delete ok");
    }

}
